let cutTime = (value, type) => {
	return value.split(" ")[0];
}

let number = (value, type) => {
	// 判断是否为数字
	// console.log(value);
	// return;
	if(isNaN(value)){
		return value;
	}
	
	// 判断是否为空
	
	if (value == null || value == '') {
		value = 0;
	}
	value = parseFloat(value);
	//处理科学计数法
	value = value.toFixed(8);
	var arr = (value + "").split(".");
	var a1 = arr[0];
	var a2 = 0;
	if (arr.length > 1) {
		a2 = arr[1];
		if (a2.length > type) {
			a2 = a2.substring(0, type);
		}
	}
	value = Number(a1 + "." + a2);
	return Number(value).toFixed(type)
}

let conceal = (value, number) => {
	if (value == undefined || value == null || value == '') {
		return value;  //解决页面渲染问题
	}else{
		return value.substring(0, number) + "****" + value.substring(value.length - number);
	}
}

// 时间格式转化
let formatTime = (value, type,time) => {
	if(time){
		const dd= value.substr(6, 2)?+ '-' + value.substr(6, 2):''
		const newTime=value.substr(0, 4) + '-' + value.substr(4, 2)+dd ;
		// console.log(value,newTime,',dd',dd)
		return  newTime
	}
	if(value == '' || value == null || value == undefined){
		return value
	}
	
	let replaceDate = value.replace(/-/g, '/');
	
	var dataTime = "";
	var data = new Date(replaceDate);
	// data.setTime(value);
	var year = data.getFullYear();
	var month_temp = data.getMonth() + 1;
	var month = month_temp < 10 ? '0' + month_temp : month_temp;
	var day = data.getDate() < 10 ? '0' + data.getDate() : data.getDate();
	var hour = data.getHours() < 10 ? '0' + data.getHours() : data.getHours();
	var minute = data.getMinutes() < 10 ? '0' + data.getMinutes() : data.getMinutes();
	var second = data.getSeconds() < 10 ? '0' + data.getSeconds() : data.getSeconds();
	if (type == "YMD") {
		dataTime = year + "-" + month + "-" + day;
	} else if (type == "YMDHMS") {
		dataTime = year + "-" + month + "-" + day + " " + hour + ":" + minute + ":" + second;
	} else if (type == "HMS") {
		dataTime = hour + ":" + minute + ":" + second;
	} else if (type == "YM") {
		dataTime = year + "-" + month;

	}
	return dataTime; //将格式化后的字符串输出到前端显示
}
export {
	cutTime
}
export {
	number
}
export {
	conceal
}
export {
	formatTime
}
